<?php

namespace common\modules\sms\models;

use common\behaviors\TimestampBehavior;
use common\components\ActiveRecord;
use Yii;
use yii\db\Expression;

/**
 * This is the model class for table "sms_customer".
 *
 * @property integer $id
 * @property string $name
 * @property string $app_id
 * @property string $app_secret
 * @property integer $quota_total
 * @property integer $quota_used
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $created_by
 * @property integer $updated_by
 */
class Customer extends ActiveRecord
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'sms_customer';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name', 'app_id', 'app_secret'], 'required'],
            [['quota_total', 'quota_used', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'integer'],
            [['name', 'app_id'], 'string', 'max' => 64],
            [['app_secret'], 'string', 'max' => 120]
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app/sms', 'ID'),
            'name' => Yii::t('app/sms', 'Name'),
            'app_id' => Yii::t('app/sms', 'App ID'),
            'app_secret' => Yii::t('app/sms', 'App Secret'),
            'quota_total' => Yii::t('app/sms', 'Quota Total'),
            'quota_used' => Yii::t('app/sms', 'Quota Used'),
            'created_at' => Yii::t('app/sms', 'Created At'),
            'updated_at' => Yii::t('app/sms', 'Updated At'),
            'created_by' => Yii::t('app/sms', 'Created By'),
            'updated_by' => Yii::t('app/sms', 'Updated By'),
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors[] = [
            'class' => TimestampBehavior::className(),
            'createdAtAttribute' => 'created_at',
            'updatedAtAttribute' => 'updated_at',
            'value' => new Expression('NOW()'),
        ];
        
        return $behaviors;
    }


    
}
